# eric7.Utilities.FtpUtilities

Module implementing some FTP related utilities.

### Global Attributes

None

### Classes

FtpDirLineParser | Class to parse lines returned by a FTP LIST command.
FtpDirLineParserError | Exception class raised, if a parser issue was detected.

### Functions

None

## FtpDirLineParser

Class to parse lines returned by a FTP LIST command.

### Derived from

QObject

### Class Attributes

MonthnamesNumbers

### Class Methods

None

### Methods

FtpDirLineParser | Constructor
__ignoreLine | Private method to check, if the line should be ignored.
__parseUnixLine | Private method to parse a Unix style directory listing line.
__parseUnixMode | Private method to parse a Unix mode string modifying the given URL info object.
__parseUnixTime | Private method to parse a Unix date and time indication modifying the given URL info object.
__parseWindowsLine | Private method to parse a Windows style directory listing line.
__parseWindowsTime | Private method to parse a Windows date and time indication modifying the given URL info object.
__splitUnixLine | Private method to split a line of a Unix like directory listing.
parseLine | Public method to parse a directory listing line.

### Static Methods

None

#### FtpDirLineParser (Constructor)

FtpDirLineParser(parent=None)

Constructor

parent (QObject)
  reference to the parent object

#### FtpDirLineParser.__ignoreLine

__ignoreLine(line)

Private method to check, if the line should be ignored.

line (str)
  to check

Return:
  flag indicating to ignore the line

Return Type:
  bool

#### FtpDirLineParser.__parseUnixLine

__parseUnixLine(line)

Private method to parse a Unix style directory listing line.

line (str)
  directory line to be parsed

Return:
  URL info object containing the valid data

Return Type:
  EricUrlInfo

#### FtpDirLineParser.__parseUnixMode

__parseUnixMode(modeString, urlInfo)

Private method to parse a Unix mode string modifying the given URL info object.

modeString (str)
  mode string to be parsed
urlInfo (EricUrlInfo)
  reference to the URL info object

Raises FtpDirLineParserError:
  Raised if the mode cannot be parsed.

#### FtpDirLineParser.__parseUnixTime

__parseUnixTime(monthAbbreviation, day, yearOrTime, urlInfo)

Private method to parse a Unix date and time indication modifying the given URL info object.

Date time strings in Unix-style directory listings typically have one of these formats:

- "Nov 23 02:33" (month name, day of month, time)
- "May 26 2005" (month name, day of month, year)

monthAbbreviation (str)
  abbreviation of the month name
day (str)
  day of the month
yearOrTime (str)
  string giving the year or a time
urlInfo (EricUrlInfo)
  reference to the URL info object

Raises FtpDirLineParserError:
  Raised if the month abbreviation is not recognized.

#### FtpDirLineParser.__parseWindowsLine

__parseWindowsLine(line)

Private method to parse a Windows style directory listing line.

line (str)
  directory line to be parsed

Return:
  URL info object containing the valid data

Return Type:
  EricUrlInfo

Raises FtpDirLineParserError:
  Raised if the line is not of a recognized Windows format.

#### FtpDirLineParser.__parseWindowsTime

__parseWindowsTime(date, time, urlInfo)

Private method to parse a Windows date and time indication modifying the given URL info object.

Date time strings in Windows-style directory listings typically have the format "10-23-12 03:25PM" (month-day_of_month-two_digit_year, hour:minute, am/pm).

date (str)
  date string
time (str)
  time string
urlInfo (EricUrlInfo)
  reference to the URL info object

Raises FtpDirLineParserError:
  Raised if either of the strings is not recognized.

#### FtpDirLineParser.__splitUnixLine

__splitUnixLine(line)

Private method to split a line of a Unix like directory listing.

It splits the line into meta data, number of links, user, group, size, month, day, year or time and name.

line (str)
  directory line to split

Return:
  tuple of nine strings giving the meta data, number of links, user, group, size, month, day, year or time and name

Return Type:
  tuple

Raises FtpDirLineParserError:
  Raised if the line is not of a recognized Unix format.

#### FtpDirLineParser.parseLine

parseLine(line)

Public method to parse a directory listing line.

This implementation support Unix and Windows style directory listings. It tries Unix style first and if that fails switches to Windows style. If that fails as well, an exception is raised.

line (str)
  directory line to be parsed

Return:
  URL info object containing the valid data

Return Type:
  EricUrlInfo

Up

## FtpDirLineParserError

Exception class raised, if a parser issue was detected.

### Derived from

Exception

### Class Attributes

None

### Class Methods

None

### Methods

None

### Static Methods

None

Up